package com.yx;

import com.github.tobato.fastdfs.FdfsClientConfig;
import com.yx.config.HeadersCORSFilter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

@Import(FdfsClientConfig.class)
@SpringBootApplication
@EnableCaching
public class YouxiangApplication extends SpringBootServletInitializer {

	public static void main(String[] args) {
		SpringApplication.run(YouxiangApplication.class, args);
	}

	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
		return application.sources(YouxiangApplication.class);
	}

	@Bean
	public FilterRegistrationBean testFilterRegistration() {
		FilterRegistrationBean registration = new FilterRegistrationBean();
		registration.setFilter(new HeadersCORSFilter());
		registration.addUrlPatterns("/*");
		registration.setName("HeadersCORSFilter");
		registration.setOrder(1);
		return registration;
	}
}
